import request from '@/utils/request'

// 查询商户信息列表
export function listGoodsInfo(query) {
  return request({
    url: '/business/goodsInfo/list',
    method: 'get',
    params: query
  })
}

// 查询商户信息详细
export function getGoodsInfo(id) {
  return request({
    url: '/business/goodsInfo/' + id,
    method: 'get'
  })
}

// 新增商户信息
export function addGoodsInfo(data) {
  return request({
    url: '/business/goodsInfo',
    method: 'post',
    data: data
  })
}

// 修改商户信息
export function updateGoodsInfo(data) {
  return request({
    url: '/business/goodsInfo',
    method: 'put',
    data: data
  })
}

// 删除商户信息
export function delGoodsInfo(id) {
  return request({
    url: '/business/goodsInfo/' + id,
    method: 'delete'
  })
}
// 删除商户信息
export function addShopCartBatchs(id) {
  return request({
    url: '/business/shoppingCartItem/addShopCartBatchInfo/' + id,
    method: 'post'
  })
}

// 删除商户信息
export function addShopCartInfo(query) {
  return request({
    url: '/business/shoppingCartItem/addShopCartInfo/',
    method: 'post',
    params: query
  })
}

export function listGoodsChangeRecord(query) {
  return request({
    url: '/business/goodsChangeRecord/myList',
    method: 'get',
    params: query
  })
}

export function listTemplatesInfo() {
  return request({
    url: '/business/freightTemplate/allList',
    method: 'get'
  })
}
export function listBrandsInfo() {
  return request({
    url: '/business/admin/brand/allList',
    method: 'get'
  })
}
export function listCategoryInfo() {
  return request({
    url: '/business/admin/category/allList',
    method: 'get'
  })
}
export function listLabelInfo() {
  return request({
    url: '/business/admin/label/allList',
    method: 'get'
  })
}

export function listMerchantLevelInfo() {
  return request({
    url: '/business/admin/merchantLevel/allList',
    method: 'get'
  })
}




export function localGet (key) {
  const value = window.localStorage.getItem(key)
  try {
    return JSON.parse(window.localStorage.getItem(key))
  } catch (error) {
    return value
  }
}

export function localSet (key, value) {
  window.localStorage.setItem(key, JSON.stringify(value))
}

// 判断内容是否含有表情字符，现有数据库不支持。
export function hasEmoji (str = '') {
  const reg = /[^\u0020-\u007E\u00A0-\u00BE\u2E80-\uA4CF\uF900-\uFAFF\uFE30-\uFE4F\uFF00-\uFFEF\u0080-\u009F\u2000-\u201f\u2026\u2022\u20ac\r\n]/g;
  return str.match(reg) && str.match(reg).length
}

// export const uploadImgServer = 'http://localhost/dev-api/manage-api/v1/upload/file/' // 正式

export const uploadImgServer = '/dev-api/common/upload?type=' // 正式

export const uploadImgServerMaster = '/dev-api/common/upload?type=master' // 正式

export const uploadImgServerDetail = '/dev-api/common/upload?type=detail' // 正式
//
// export function uploadImgServer() {
//   return request({
//     url: '/business/goodsInfo/upload/file',
//     method: 'post'
//   })
// }


// 删除商户信息
export function downLoadImgZip(query) {
  return request({
    url: '/business/goodsInfo/downLoadImgZip',
    method: 'post',
    params: query
  })
}


export function listMerchantInfo() {
  return request({
    url: '/business/admin/merchant/allList',
    method: 'get'
  })
}

// 商品活动价格
export function listGoodsActivityPrice(id) {
  return request({
    url: '/business/goodsInfo/goodsActivityPriceList?id='+id,
    method: 'get',
  })
}

// 操作店铺信息
export function operate(query) {
  return request({
    url: '/business/goodsInfo/operate',
    method: 'post',
    params: query
  })
}